public  class Cbl_EventSumWeekPlan {
	
	public static void sumWeekPlan(List<Event> list_event){
		//AccountId
		Set<Id> Set_WkId=new Set<Id>();
		for(Event ord:list_event)
		{
			if(ord.Week_Plan__c != null )Set_WkId.add(ord.Week_Plan__c);
		}
		List<Weekly_Plan__c> list_WekPlan=new List<Weekly_Plan__c>();
	
		if(Set_WkId.isEmpty())return;
		
		AggregateResult[] sumManday = 
		[select Week_Plan__c,sum(Travel_Fee__c) chl,sum(Busness_Fee__c) mef from Event
        where Week_Plan__c IN: Set_WkId 
        group by Week_Plan__c];
                                   
	    for(AggregateResult ar : sumManday)
	    {
	    	if(ar.get('Week_Plan__c')!=null)
	    	{
	    		Weekly_Plan__c acc = new Weekly_Plan__c(
	                               id=id.valueOf(String.valueof(ar.get('Week_Plan__c')))
	                               ,Travel_Total__c = Double.valueOf(ar.get('chl'))
	                               ,Business_Total__c = Double.valueOf(ar.get('mef')));
	    		list_WekPlan.add(acc);
	    	}
	        
	    }
	    update list_WekPlan;
	}

}